package edu.guigu.uiweixindemo.talk;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

import edu.guigu.uiweixindemo.R;

public class TalkAdapter extends RecyclerView.Adapter<TalkAdapter.TalkViewHold> {

    private List<TalkInfo> talkInfos;

    public TalkAdapter() {
        this.talkInfos = new ArrayList<TalkInfo>();
    }

    public void setTalkInfos(List<TalkInfo> talkInfos) {
        this.talkInfos = talkInfos;
    }

    @NonNull
    @Override
    public TalkViewHold onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_talk, parent, false);
        TalkViewHold viewHold = new TalkViewHold(view);
        return viewHold;
    }

    @Override
    public void onBindViewHolder(@NonNull TalkViewHold holder, int position) {
//        holder.tvIcon.setImageURI();
        holder.tvTitle.setText(talkInfos.get(position).getTitle());
    }

    @Override
    public int getItemCount() {
        return talkInfos.size();
    }

    public class TalkViewHold extends RecyclerView.ViewHolder{

        public TextView tvTitle;
        public ImageView tvIcon;

        public TalkViewHold(@NonNull View itemView) {
            super(itemView);
            tvTitle = itemView.findViewById(R.id.tv_title);
            tvIcon = itemView.findViewById(R.id.iv_icon);
        }
    }
}
